//
//  ACLFUCache.h
//  Cache
//
//  Created by caixiang on 2021/8/14.
//

#import <Foundation/Foundation.h>


NS_ASSUME_NONNULL_BEGIN

@interface ACLFUCache : NSObject

@property NSUInteger countLimit;
@property NSUInteger costLimit;

@property (readonly) NSUInteger totalCount;
@property (readonly) NSUInteger totalCost;

@property BOOL shouldRemoveAllObjectsOnMemoryWarning;
@property BOOL shouldRemoveAllObjectsWhenEnteringBackground;

@property (nullable, copy) void(^didReceiveMemoryWarningBlock)(ACLFUCache *cache);
@property (nullable, copy) void(^didEnterBackgroundBlock)(ACLFUCache *cache);

- (BOOL)containsObjectForKey:(id)key;
- (nullable id)objectForKey:(id)key;
- (void)setObject:(nullable id)object forKey:(id)key;
- (void)setObject:(nullable id)object forKey:(nonnull id)key cost:(NSUInteger)cost;
- (void)removeObjectForKey:(id)key;
- (void)removeAllObjects;

- (NSArray *)allkeys;
- (NSArray *)allValues;

- (void)trimToCost:(NSUInteger)costLimit;
- (void)trimToCount:(NSUInteger)countLimit;

@end

NS_ASSUME_NONNULL_END
